package com.example.springbootnodb.entity;

import com.example.springbootnodb.annontation.EnumString;
import com.example.springbootnodb.controller.ValidController;
import com.example.springbootnodb.group.ValidGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

@Data
public class ValidVO {

    /**
     * 创建组id为空
     * 更新组id不能为空
     * @see ValidController#update(com.example.springbootnodb.entity.ValidVO)
     */
    @Null(groups = ValidGroup.Crud.Create.class)
    @NotNull(groups = ValidGroup.Crud.Update.class, message = "应用ID不能为空")
    private String id;

    @Length(min = 6,max = 12,message = "appId长度必须位于6到12之间")
    private String appId;

    @NotBlank(message = "名字为必填项")
    private String name;

    @Email(message = "请填写正确的邮箱地址")
    private String email;

    /**
     * 自定义校验注解
     */
    @EnumString(value = {"F","M"}, message="性别只允许为F或M")
    private String sex;

    @NotEmpty(message = "级别不能为空")
    private String level;
}